package com.olocat.cjx.nsims.pojo.entry

import com.fasterxml.jackson.annotation.JsonFormat
import com.fasterxml.jackson.annotation.JsonIgnoreProperties
import com.olocat.cjx.nsims.pojo.info.OperationLog
import com.olocat.cjx.nsims.pojo.personnel.Doctor
import org.hibernate.annotations.GenericGenerator
import java.sql.Timestamp
import javax.persistence.*

@Entity
@Table(name = "entry_doctor")
@JsonIgnoreProperties(value = ["hibernateLazyInitializer", "handler"])
class EntryDoctor {
    @Id
    @GeneratedValue(generator = "entry_nurse_generator")
    @GenericGenerator(name = "entry_nurse_generator", strategy = "uuid")
    var id: String? = null
    var name: String? = null
    var age: Int? = null
    var gender: Boolean? = null

    @Column(name = "car_type")
    var carType: Int? = null

    @Column(name = "car_id")
    var carId: String? = null
    var phone: String? = null
    var department: Int? = null
    var level: Int? = null
    var description: String? = null
    var applicant: String? = null

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    var time: Timestamp? = null
    var avatar: String? = null
    var state: Byte = 0
    var step: Int = 0

    @OneToMany
    @JoinColumn(name = "person_id")
    var operationLog: List<OperationLog>? = null

    fun toDoctor(): Doctor {
        return Doctor(null, name!!, carId!!, age!!, phone!!, department!!, level!!,
                carType!!, gender!!)
    }

    override fun toString(): String {
        return "EntryDoctor{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                ", gender=" + gender +
                ", carType=" + carType +
                ", carId='" + carId + '\'' +
                ", phone='" + phone + '\'' +
                ", department=" + department +
                ", level=" + level +
                ", description='" + description + '\'' +
                ", applicant='" + applicant + '\'' +
                ", time=" + time +
                ", avatar='" + avatar + '\'' +
                '}'
    }
}